package cc.sheji.reposity;

import cc.sheji.domain.Job;
import cc.sheji.domain.MyPhoto;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Repository
public interface MyPhotoRepository extends CrudRepository<MyPhoto, Long>, JpaSpecificationExecutor<MyPhoto> {


    @Modifying
    @Transactional
    @Query(value = "update MyPhoto  set pictureCollectionId=:id where  id in (:ids)")
    int updateParentId(@Param("id") Long id, @Param("ids") List<Long> ids);

    @Query(value = "SELECT * FROM my_photo  where  `picture_collection_id` =:id ORDER BY create_time desc " ,nativeQuery = true)
    List<MyPhoto> getList(@Param("id") Long id);
}
